package com.xbongbong.pro.enums;

import com.xbongbong.paas.constant.ShareConditionConstant;
import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author 李翔
 * @date 2023/3/3
 * @description
 */
@Getter
public enum ShareRuleFilterConditionEnum {
    //单行文本
    TEXT(FieldTypeEnum.TEXT.getType(), ShareConditionConstant.TEXT),
    //多行文本
    TEXTAREA(FieldTypeEnum.TEXTAREA.getType(), ShareConditionConstant.TEXTAREA),
    //数字
    NUM(FieldTypeEnum.NUM.getType(), ShareConditionConstant.NUM),
    //日期
    DATETIME(FieldTypeEnum.DATETIME.getType(), ShareConditionConstant.DATETIME),
    //单选按钮
    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP.getType(), ShareConditionConstant.RADIO_GROUP),
    //复选框组
    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP.getType(), ShareConditionConstant.CHECKBOX_GROUP),
    //下拉框
    COMBO(FieldTypeEnum.COMBO.getType(), ShareConditionConstant.COMBO),
    //下拉框复选
    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK.getType(), ShareConditionConstant.COMBO_CHECK),
    //地址
    ADDRESS(FieldTypeEnum.ADDRESS.getType(), ShareConditionConstant.ADDRESS),
    //标签
    LABEL(FieldTypeEnum.LABEL.getType(),ShareConditionConstant.LABEL),
    //子表单
    SUB_FORM(FieldTypeEnum.SUB_FORM.getType(), null),
    //关联数据
    LINK_DATA(FieldTypeEnum.LINK_DATA.getType(), ShareConditionConstant.LINK_DATA),
    //关联数据多选
    LINK_DATA_MULTI(FieldTypeEnum.LINK_DATA_MULTI.getType(), ShareConditionConstant.LINK_DATA_MULTI),
    //成员单选
    USER(FieldTypeEnum.USER.getType(), ShareConditionConstant.USER),
    //成员多选
    USER_GROUP(FieldTypeEnum.USER_GROUP.getType(), ShareConditionConstant.USER_GROUP),
    //部门单选
    DEPT(FieldTypeEnum.DEPT.getType(), ShareConditionConstant.DEPT),
    //部门多选
    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP.getType(), ShareConditionConstant.DEPT_GROUP),
    //阶段推进器
    STAGE_THRUSTER(FieldTypeEnum.STAGE_THRUSTER.getType(), ShareConditionConstant.STAGE_THRUSTER),
    //创建人
    CREATORID(FieldTypeEnum.CREATORID.getType(), ShareConditionConstant.CREATORID),
    //创建时间
    ADDTIME(FieldTypeEnum.ADDTIME.getType(), ShareConditionConstant.ADDTIME),
    //更新时间
    UPDATETIME(FieldTypeEnum.UPDATETIME.getType(), ShareConditionConstant.UPDATETIME),
    //所属部门
    DEPARTMENTID(FieldTypeEnum.DEPARTMENTID.getType(), ShareConditionConstant.DEPARTMENTID),
    //负责人
    OWNERID(FieldTypeEnum.OWNERID.getType(), ShareConditionConstant.OWNERID),
    //协同人
    COUSERID(FieldTypeEnum.COUSERID.getType(), ShareConditionConstant.COUSERID),
    //流水号
    SERIALNO(FieldTypeEnum.SERIALNO.getType(), ShareConditionConstant.SERIALNO),
    //关联业务单选
    LINK_BUSINESS_SINGLE(FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), ShareConditionConstant.LINK_BUSINESS_SINGLE),
    //关联业务多选
    LINK_BUSINESS_MULTI(FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), ShareConditionConstant.LINK_BUSINESS_MULTI),
    //阶段比例
    STAGE_RATIO(FieldTypeEnum.STAGE_RATIO.getType(), ShareConditionConstant.STAGE_RATIO),
    //客户生日
//    BIRTHDAY(FieldTypeEnum.BIRTHDAY.getType(), ShareConditionConstant.BIRTHDAY),
    ;

    /**
     * fieldTypeCode
     */
    private final Integer code;
    private final String[] ConditionFields;

    ShareRuleFilterConditionEnum(Integer code, String[] ConditionFields) {
        this.code = code;
        this.ConditionFields = ConditionFields;
    }

    /**
     * 根据code值获取枚举
     * @param code
     * @return
     */
    public static ShareRuleFilterConditionEnum getByCode(Integer code) {
        for (ShareRuleFilterConditionEnum cacheCode : values()) {
            if (Objects.equals(cacheCode.code,code)) {
                return cacheCode;
            }
        }
        return null;
    }

    /**
     * 创建人、创建时间、更新时间、所属部门、负责人、协同人、流水号几类系统字 是系统表单默认支持
     * @return
     */
    public static List<Integer> extraSystemSupportField() {
        return Arrays.asList(CREATORID.getCode(), ADDTIME.getCode(), UPDATETIME.getCode(), DEPARTMENTID.getCode()
                , OWNERID.getCode(), COUSERID.getCode(), SERIALNO.getCode());
    }

}
